//
//  QCCheckResultswift
//  爱汽车
//
//  Created by tucici on 2024/1/6.
//

import UIKit

class QCCheckResultCell: UICollectionViewCell {
    var img:UIImageView!
    var content:UILabel!
    override init(frame: CGRect) {
        super.init(frame: frame)
        initUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func initUI(){
        backgroundColor = .clear
        contentView.backgroundColor = .clear
        img = UIImageView(image: UIImage(named: "异常"))
        content = UILabel()
        contentView.addSubview(img)
        contentView.addSubview(content)
        
        img.snp.remakeConstraints { make in
            make.left.equalToSuperview().offset(20)
            make.size.equalTo(CGSize(width: 34, height: 34))
            make.centerY.equalToSuperview()
        }
    }
    
    var success = true{
        didSet{
            img.isHidden = success
            content.textAlignment = success ? .center : .left
            content.textHexColor = success ? "#FF4D00" : "#FFFFFF"
            content.font = success ? UIFont.systemFont(ofSize: 19, weight: .bold) : UIFont.systemFont(ofSize: 16)
            
            content.snp.remakeConstraints { make in
                make.right.equalToSuperview().inset(20)
                make.centerY.equalToSuperview()
                if success{
                    make.left.equalToSuperview().inset(20)
                }else{
                    make.left.equalTo(img.snp.right).offset(16)
                }
            }
        }
    }
}
